
/**	\file		RealGraph.h
*	\author		Abbas Bazzi
*	\author		Farah Charab
*	\author		Rafah El-Khatib
*	\brief		Another header file that traverses the graph created in Graph.h, the other header file
*/

#ifndef _REALGRAPH_H_
#define _REALGRAPH_H_
#include "Graph.h"
#include <iostream>
#include <string>
using namespace std;

/**	\typedef	MapFromStringToIndex
*	\param		A string to index the map.
*	\brief		Map from string to integer, where the integer will represent a certain index.
*/
typedef map <string,int> MapFromStringToIndex;
/**	\typedef	MapFromIndextoString
*	\param		An integer to index the map.
*	\brief		Map from integer to string.
*/
typedef map <int,string> MapFromIndextoString;

/**	\class		RealGraph
	\brief		A graph that consists of a node vector, an edge vector, and a map that maps a node to an integer indicator. It also contains the traverse function and two visit functions: one for the Nodes and one for the Edges.
*/
class RealGraph{
public:
	vector <NODE> Nodes;//!< A vector of nodes of type NODE.
	vector <EDGE> Edges;//!< A vector of edges of type EDGE.
	map <string,int> NodeIndex;//!< A map from string to integer that is used to map a node to its unique index in the graph.
/**
*	\param		N A vector of the nodes of the graph
*	\param		E A vector of the edges of the graph
*	\param		NI A mao from string to integer that maps a node to its index
*	\brief		A constructor of the class RealGraph that initializes its vectors of nodes and edges, and its defining map, to passed parameters.
*/
	RealGraph(vector <NODE> &N, vector<EDGE>&E, map<string,int> &NI);
/**
*	\brief		A constructor of the class RealGraph that initializes its vectors of nodes and edges, and its defining map, to empty structures.
*/
	RealGraph(){};
/**
*	\brief		A print function that outputs the contents of our constructed graph.
*/
	void print();
/**
*	\brief		Traversal Function that goes over a graph by visiting its nodes and all its adjacent ones. The adjacent nodes are found using the Edges vector: All nodes adjacent to a node n1 are in the vector appended to the entry of the adjacency list indexed by n1.
*/
	void traverse();
/**
*	\param		TypeOfNode An integer which indicates the type of the node
*	\param		data A string which holds the content of the node
*	\param		map An integer which serves as the index in the map NodeIndex
*	\brief		A function that updates the graph and adds a new node to it, given the node's type, data, and index.
*/
	void addNode(int TypeOfNode,string data,int map);
/**
*	\param		mapSource An integer which maps the source of the edge to an index to make its content accessible in the graph
*	\param		mapDest An integer which maps the destination of the edge to an index to make its content accessible in the graph
*	\param		realSource A string which is the real name of the source node
*	\param		realDest A string which is the real name of the destination node
*	\param		EdgeWeight A string that indicates whether or not the edge is right- or left-natured.
*	\param		i An integer that maps to the edge number in the vector
*	\brief		A constructor of the class RealGraph that initializes its vectors of nodes and edges, and its defining map, to passed parameters.
*/	
	void addEdge(int mapSource,int mapDest,string realSource,string realDest,string EdgeWeight,int i);
/**
*	\param		name A constant character array that indicates the name of the node
*	\param		type A constant character array that indicates the type of the node.
*	\param		fake A constant character array that holds the modified name of the node (with index appended).
*	\brief		A function that visits a node. It does nothing but it gets excecuted in the aspect
*/
	void VisitNode(const char * name, const char* type, const char * fake);
/**
*	\param		source A constant character array that indicates the name of the source node of the edge.
*	\param		dest A constant character array that indicates the name of the destination node of the edge.
*	\param		weight A constant character array that indicates whether the edge is right- or left-natured.
*	\brief		A function that visits an edge. It does nothing but it gets executed in the aspect.
*/
	void VisitEdge(const char * source, const char * dest,const char* weight);
/**
*	\brief		A function used for testing purposes.
*/
	void test();
private:
	MapFromStringToIndex OccurrenceCounter;//!< A map from string to integer that keeps track of the frequency of the occurrence of variables or operators to ensure uniqueness and the graph's tree structure.
	MapFromIndextoString IndexToFake;//!< A map from integer to string that maps an index to the modified variable/operator name.
};

#endif
